﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SQLExecute;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;


public partial class profile_detail_edu_en : System.Web.UI.Page
{
    DataSet ds;
    public string strGraduationDegree;
    public string strWorkingExperience;
    Profiles p = new Profiles();
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
        {
            if (Request.Params["id"] == null)
            {
                Response.Redirect("list_profiles.aspx");         
            }
            else
            {
                Get_Profile_Info();
                Set_Profile_Info();
                Set_Skills_Qualification();
                Set_Working_Experience();
                Set_Interview_Evaluation();
                Set_Recruitement_Info();
              

            }
        }
    }

    private void Get_Profile_Info()
    {
        Guid id = new Guid(Request.QueryString[0]);

        p.ID = id;

        ds = p.Get_Profile();
    }
    private void Set_Profile_Info()
    {
        lFullName.Text = ds.Tables[0].Rows[0]["fullname"].ToString().ToUpper();
        
        lSex.Text = ds.Tables[0].Rows[0]["sex"].ToString();
        lEmail.Text = ds.Tables[0].Rows[0]["mail"].ToString();


        if (ds.Tables[0].Rows[0]["number_of_childrens"].ToString() != "")

            lMartialStatus.Text = ds.Tables[0].Rows[0]["married"].ToString() + "-" + ds.Tables[0].Rows[0]["number_of_childrens"].ToString();
        else if (ds.Tables[0].Rows[0]["married_status_others"].ToString() != "")
            lMartialStatus.Text = ds.Tables[0].Rows[0]["married"].ToString() + "-" + ds.Tables[0].Rows[0]["married_status_others"].ToString();
        else
            lMartialStatus.Text = ds.Tables[0].Rows[0]["married"].ToString();

        string s = ds.Tables[0].Rows[0]["phone"].ToString();
        //s = s.Substring(0, 4)+ " - " +s.Substring(4,3)+" "+ s.Substring(7,3);
        //s=s.Insert(7," ");
        //lTele.Text = s;

        if (ds.Tables[0].Rows[0]["phone"].ToString()!="")
        lTele.Text =Common.Split_Number_Tele(ds.Tables[0].Rows[0]["phone"].ToString());
        lHeight.Text = ds.Tables[0].Rows[0]["height"].ToString();
        lWeight.Text = ds.Tables[0].Rows[0]["weight"].ToString();

        if (ds.Tables[0].Rows[0]["birth"].ToString() != "")
        {
            //Convert.ToDateTime(ds.Tables[0].Rows[0]["availabledate"].ToString()).ToString("dd/MM/yyyy");
            lDateOfbirth.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["birth"].ToString()).ToString("dd/MM/yyyy");
                //DateTime.Parse(ds.Tables[0].Rows[0]["birth"].ToString()).ToShortDateString();
        }
        lPos.Text = ds.Tables[0].Rows[0]["pos"].ToString();

        if (ds.Tables[0].Rows[0]["expectedsalary"].ToString() != "" && ds.Tables[0].Rows[0]["expectedsalary"].ToString() != "0")
        {
            Decimal money = Decimal.Parse(ds.Tables[0].Rows[0]["expectedsalary"].ToString());

            lExpectedSalary.Text = String.Format("${0:#,###}", money);
        }
        else
        {
            lExpectedSalary.Visible = false;
            lCurrentSalary.Visible = false;
        }

        //lExpectedSalary.Text =Decimal.Parse(ds.Tables[0].Rows[0]["expectedsalary"].ToString()).ToString();
        if (ds.Tables[0].Rows[0]["availabledate"].ToString().Length > 0)
            lAvailableDate.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["availabledate"].ToString()).ToString("dd/MM/yyyy");
                //DateTime.Parse(ds.Tables[0].Rows[0]["availabledate"].ToString()).ToShortDateString();
        
        lCurrentSalary.Text = ds.Tables[0].Rows[0]["currency_salary"].ToString();
        lCurrentAddress.Text = ds.Tables[0].Rows[0]["current_address"].ToString();
        lRegisteredResidence.Text = ds.Tables[0].Rows[0]["permanent_address"].ToString();
        lIDCard.Text = ds.Tables[0].Rows[0]["id_card"].ToString();
        lRelocate.Text = ds.Tables[0].Rows[0]["relocate"].ToString();

        lAptitude.Text = ds.Tables[0].Rows[0]["aptitude"].ToString();
        lKnownFrom.Text = ds.Tables[0].Rows[0]["known_from"].ToString();
        lCarreerOjectives.Text = ds.Tables[0].Rows[0]["carreerobjectives"].ToString();
        Set_Skills_Qualification();  
        Set_Working_Experience();
         
        //Set_Overal_Evaluation();


    }
    private void Set_Skills_Qualification()
    {
        /*
        ,s.degree_type,s.info_degree1,s.info_degree2,s.info_degree3,s.info_degree4
	  ,s.major1, s.major2 ,s.major3, s.major4
	  ,s.school1,s.school2,s.school3,s.school4
	  ,s.type_of_training1,s.type_of_training2,s.type_of_training3,s.type_of_training4	
	  ,s.info_degree_date1,s.info_degree_date2,s.info_degree_date3,s.info_degree_date4
	  ,s.english_skills,s.other_language,s.computer_skills,s.other_skills*/


        strGraduationDegree = ds.Tables[0].Rows[0]["degree1"].ToString()
                              + "-" + ds.Tables[0].Rows[0]["schoolname1"].ToString()
                              + "-" + ds.Tables[0].Rows[0]["major_name1"].ToString()
                              + "-" + ds.Tables[0].Rows[0]["trainingname1"].ToString()
                              +"-" + ds.Tables[0].Rows[0]["info_degree_date1"].ToString();
        if (ds.Tables[0].Rows[0]["degree2"].ToString() != ""
                                || ds.Tables[0].Rows[0]["schoolname2"].ToString() != ""
                               || ds.Tables[0].Rows[0]["major_name2"].ToString() != ""
                              || ds.Tables[0].Rows[0]["trainingname2"].ToString() != "")
        {
            strGraduationDegree += "<br />" + ds.Tables[0].Rows[0]["degree2"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["schoolname2"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["major_name2"].ToString()
                                +"-"+ds.Tables[0].Rows[0]["type_of_training2"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["trainingname2"].ToString();
            
        }

        if (ds.Tables[0].Rows[0]["degree3"].ToString() != ""
                                || ds.Tables[0].Rows[0]["schoolname3"].ToString() != ""
                               || ds.Tables[0].Rows[0]["major_name3"].ToString() != ""
                              || ds.Tables[0].Rows[0]["trainingname3"].ToString() != "")
        {
            strGraduationDegree += "<br />" + ds.Tables[0].Rows[0]["degree3"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["schoolname3"].ToString()
                                +"-"+ds.Tables[0].Rows[0]["major3"].ToString()
                                +"-"+ds.Tables[0].Rows[0]["type_of_training3"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["trainingname3"].ToString();
            
        }
        if (ds.Tables[0].Rows[0]["degree4"].ToString() != ""
                                || ds.Tables[0].Rows[0]["schoolname4"].ToString() != ""
                               || ds.Tables[0].Rows[0]["major_name4"].ToString() != ""
                              || ds.Tables[0].Rows[0]["trainingname4"].ToString() != "")
        {
            strGraduationDegree += "<br />" + ds.Tables[0].Rows[0]["degree4"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["schoolname4"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["major4"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["type_of_training4"].ToString()
                                + "-" + ds.Tables[0].Rows[0]["trainingname4"].ToString();             
        }
        lHighestDegree.Text = ds.Tables[0].Rows[0]["degree_type"].ToString();
        lEnglishLanguage.Text= ds.Tables[0].Rows[0]["english_skills"].ToString();
        lOtherLanguage.Text = ds.Tables[0].Rows[0]["other_language"].ToString();

        lComputerSkill.Text = ds.Tables[0].Rows[0]["computer_skills"].ToString();
        lOthersSkill.Text = ds.Tables[0].Rows[0]["other_skills"].ToString();


    }
    private void Set_Interview_Evaluation()
    {
        //interview 1
        ltInterview1.Text = ds.Tables[0].Rows[0]["interview1"].ToString();
        ltPos1.Text = ds.Tables[0].Rows[0]["interviewpos1"].ToString();
        ltDep1.Text = ds.Tables[0].Rows[0]["interviewdep1"].ToString();
        ltComment1.Text = ds.Tables[0].Rows[0]["comment1"].ToString();

        //interview 2
        ltInterview2.Text = ds.Tables[0].Rows[0]["interview2"].ToString();
        ltPos2.Text = ds.Tables[0].Rows[0]["interviewpos2"].ToString();
        ltDep2.Text = ds.Tables[0].Rows[0]["interviewdep2"].ToString();
        ltComment2.Text = ds.Tables[0].Rows[0]["comment2"].ToString();

        ltEnglishTestResult.Text = ds.Tables[0].Rows[0]["english_result"].ToString();
        ltWord.Text = ds.Tables[0].Rows[0]["word_result"].ToString();
        ltExcel.Text = ds.Tables[0].Rows[0]["excel_result"].ToString();
        ltConclusion.Text = ds.Tables[0].Rows[0]["interview_conclusion"].ToString();

              

        ltFinalDecision.Text = ds.Tables[0].Rows[0]["final_decision"].ToString();
        ltPos3.Text = ds.Tables[0].Rows[0]["interviewpos3"].ToString();
        ltDep3.Text = ds.Tables[0].Rows[0]["interviewdep3"].ToString();
        ltComment2.Text = ds.Tables[0].Rows[0]["comment3"].ToString();

        
    
        /* ,i.interview1,i.interviewpos1,i.interviewdep1,i.comment1
	  ,i.english_result,i.word_result,i.excel_result,i.conclusion
	  ,i.interview2,i.interviewpos2,i.interviewdep2,i.comment2,i.final_decision
	  ,i.interviewpos3,i.interviewdep3,i.comment3	
	  ,r.conclusion,r.position_offer,r.dept,r.salary,r.starting_date,r.note*/
    }
    private void Set_Recruitement_Info()
    {


        //,r.conclusion,r.position_offer,r.dept,r.salary,r.starting_date,r.note
        ltRecruitmentConclusion.Text = ds.Tables[0].Rows[0]["recruitment_conclusion"].ToString();
        ltRecruitmentPositionOffer.Text = ds.Tables[0].Rows[0]["position_offer"].ToString();
        ltRecruitmentDep.Text = ds.Tables[0].Rows[0]["dept"].ToString();
        
        if (ds.Tables[0].Rows[0]["salary"].ToString() != "" && ds.Tables[0].Rows[0]["salary"].ToString() != "0")
        {
            Decimal money = Decimal.Parse(ds.Tables[0].Rows[0]["salary"].ToString());
            ltSalary.Text = String.Format("${0:#,###}", money);
                
        }
        ltRecruitmentNote.Text = ds.Tables[0].Rows[0]["note"].ToString();
        //lDateOfbirth.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["birth"].ToString()).ToString("dd/MM/yyyy");
        if (ds.Tables[0].Rows[0]["starting_date"].ToString()!="")
            ltRecruitmentStartingDate.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["starting_date"].ToString()).ToString("dd/MM/yyyy");
            //ds.Tables[0].Rows[0]["starting_date"].ToString();
        

    }
    private void Set_Working_Experience()
    {
       

        string s1=string.Empty, s2=string.Empty, s3=string.Empty, s4=string.Empty;
        /*
        if (ds.Tables[0].Rows[0]["info_degree1"].ToString() != "" &&
             ds.Tables[0].Rows[0]["school1"].ToString() != "" &&
             ds.Tables[0].Rows[0]["major1"].ToString() != "" &&
             ds.Tables[0].Rows[0]["type_of_training1"].ToString() != "" &&
             ds.Tables[0].Rows[0]["info_degree_date1"].ToString() != "")

            s1 = ds.Tables[0].Rows[0]["info_degree1"].ToString() + " School: "
                 + ds.Tables[0].Rows[0]["school1"].ToString() + " Major: "
                  + ds.Tables[0].Rows[0]["major1"].ToString() + " Training: "
                  + ds.Tables[0].Rows[0]["type_of_training1"].ToString() + " study period: "
                  + ds.Tables[0].Rows[0]["info_degree_date1"].ToString();

        if ( ds.Tables[0].Rows[0]["info_degree2"].ToString() !=""&&
             ds.Tables[0].Rows[0]["school2"].ToString()!=""&&
             ds.Tables[0].Rows[0]["major2"].ToString() !=""&&
             ds.Tables[0].Rows[0]["type_of_training2"].ToString()!=""&&
             ds.Tables[0].Rows[0]["info_degree_date2"].ToString()!="")
             s2 = ds.Tables[0].Rows[0]["info_degree2"].ToString() + " School: "
                              + ds.Tables[0].Rows[0]["school2"].ToString() + " Major: "
                              + ds.Tables[0].Rows[0]["major2"].ToString() + " Training: "
                              + ds.Tables[0].Rows[0]["type_of_training2"].ToString() + " study period: "
                              + ds.Tables[0].Rows[0]["info_degree_date2"].ToString();

      if (ds.Tables[0].Rows[0]["info_degree3"].ToString() !=""&&
          ds.Tables[0].Rows[0]["school3"].ToString() !=""&&
          ds.Tables[0].Rows[0]["major3"].ToString() !=""&&
          ds.Tables[0].Rows[0]["type_of_training3"].ToString() !=""&&
          ds.Tables[0].Rows[0]["info_degree_date3"].ToString()!="")
          s3 = ds.Tables[0].Rows[0]["info_degree3"].ToString() + " School: "
                              + ds.Tables[0].Rows[0]["school3"].ToString() + " Major: "
                              + ds.Tables[0].Rows[0]["major3"].ToString() + " Training: "
                              + ds.Tables[0].Rows[0]["type_of_training3"].ToString() + " study period: "
                              + ds.Tables[0].Rows[0]["info_degree_date3"].ToString();
 
        if (ds.Tables[0].Rows[0]["info_degree4"].ToString()!=""&&
            ds.Tables[0].Rows[0]["school4"].ToString()!=""&&
            ds.Tables[0].Rows[0]["major4"].ToString() !=""&&
            ds.Tables[0].Rows[0]["type_of_training4"].ToString()!=""&&
            ds.Tables[0].Rows[0]["info_degree_date4"].ToString()!="")

            s4 = ds.Tables[0].Rows[0]["info_degree4"].ToString() + " School: "
                              + ds.Tables[0].Rows[0]["school4"].ToString() + " Major: "
                              + ds.Tables[0].Rows[0]["major4"].ToString() + " Training: "
                              + ds.Tables[0].Rows[0]["type_of_training4"].ToString() + " study period: "
                              + ds.Tables[0].Rows[0]["info_degree_date4"].ToString();

        if (s1.Length > 0)
            strGraduationDegree += s1;
        //else s1 = string.Empty;
        if (s2.Length > 0)
            strGraduationDegree += "<br />" + s2;
        if (s3 != "")
            strGraduationDegree += "<br />" + s3;
        if (s4 != "")
            strGraduationDegree += "<br />" + s4;



        string s5 = string.Empty, s6 = string.Empty, s7 = string.Empty;


        if ( ds.Tables[0].Rows[0]["employer1"].ToString()!=""&&
              ds.Tables[0].Rows[0]["pos1"].ToString()!=""&&
              ds.Tables[0].Rows[0]["sal1"].ToString()!=""&&
              ds.Tables[0].Rows[0]["supervisor1"].ToString()!="")

        s5 = ds.Tables[0].Rows[0]["employer1"].ToString() + " Position title: "
                             + ds.Tables[0].Rows[0]["pos1"].ToString() + " Salary: "
                             + ds.Tables[0].Rows[0]["sal1"].ToString() + " Supervisor / Line Manager :"
                             + ds.Tables[0].Rows[0]["supervisor1"].ToString();

        if (ds.Tables[0].Rows[0]["employer2"].ToString() != "" &&
                ds.Tables[0].Rows[0]["pos2"].ToString() != "" &&
                ds.Tables[0].Rows[0]["sal2"].ToString() != "" &&
                ds.Tables[0].Rows[0]["supervisor2"].ToString() != "")

            s6 = ds.Tables[0].Rows[0]["employer2"].ToString() + " Position title: "
                                 + ds.Tables[0].Rows[0]["pos2"].ToString() + " Salary: "
                                 + ds.Tables[0].Rows[0]["sal2"].ToString() + " Supervisor / Line Manager :"
                                 + ds.Tables[0].Rows[0]["supervisor2"].ToString();


        if (ds.Tables[0].Rows[0]["employer3"].ToString() != "" &&
                      ds.Tables[0].Rows[0]["pos3"].ToString() != "" &&
                      ds.Tables[0].Rows[0]["sal3"].ToString() != "" &&
                      ds.Tables[0].Rows[0]["supervisor3"].ToString() != "")

            s7 = ds.Tables[0].Rows[0]["employer3"].ToString() + " Position title: "
                                 + ds.Tables[0].Rows[0]["pos3"].ToString() + " Salary: "
                                 + ds.Tables[0].Rows[0]["sal3"].ToString() + " Supervisor / Line Manager :"
                                 + ds.Tables[0].Rows[0]["supervisor3"].ToString();

     


        if (s5 != "")
            strWorkingExperience += s5;
        if (s6 != "")
            strWorkingExperience += "<br />" + s6;
        if (s7 != "")
            strWorkingExperience += "<br />" + s7;
     
        */

    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Redirect("list_profiles.aspx");
    }
    protected void btnPrint_Click(object sender, EventArgs e)
    {

        Response.Redirect("~/reports/print_profile.aspx?id="+Request.QueryString["id"].ToString());
         

    }
}


